import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;


public class HandleDropdownbutton {

	public static void main(String[] args) throws InterruptedException {
//HANDLING DROPDOWN BUTTONS ON INDIGO WEBSITE USING WEBDRIVER API
//GO TO INDIGO WEBSITE
		
		WebDriver driver = new FirefoxDriver();
		driver.get("http:www.goindigo.in");
		
//CREATE VARIABLE address WITH TYPE WEBELEMENT BECAUSE IN JAVA WE CREATE VARIABLE WITH TYPE 
// EXAMPLE IF WE WRITE x=4; IT WILL THROW AN ERROR SO WE WRITE INT x= 4;(INT IS TYPE & X IS VARIABLE)
WebElement address= driver.findElement(By.xpath(".//*[@id='indiGoRoundTripSearch_PassengerCounts_0__Count']"));
//CREATE CLASS NAME SELECT & OBJECT NAME AB OR ABC//import orgqa support.ui to remove redlines on left 
//PASS ARGUMENT IN RIGHT SELECT so that select ab can point to address			
		Select ab= new Select(address);
		//ab now has select and address capabilities
//TYPE ab. and SELECT OPTION selectByVisibleText(text) TO SELECT NUMBER OF PASSENGER;
		ab.selectByVisibleText("5 Adults");
		Thread.sleep(5000L);
//WE CAN ALSO USE ab.selectByIndex();...AND TYPE THE NUMBER TO SELECT THE OPTION (0,1,2,3,4)
		ab.selectByIndex(3);
		
		driver.close();
		

	}

}
